package com.woniu.admin.vo;

import lombok.Data;

import java.util.HashMap;
import java.util.Map;

@Data
public class AjaxResult extends HashMap<String, Object> {
    private static final Integer SUCCESS = 200;
    private static final Integer ERROR = 500;

    private static final String ERROR_MSG = "系统异常";

    private static final String CODE = "code";
    private static final String MSG = "msg";
    private static final String DATA = "data";

    public AjaxResult(Integer code, String msg, Object data) {
        this.put(CODE, code);
        this.put(MSG, msg);
        this.put(DATA, data);
    }
    public static AjaxResult success(String msg, Object data) {
        return new AjaxResult(SUCCESS, msg, data);
    }

    public static AjaxResult success(String msg) {
        return new AjaxResult(SUCCESS, msg, null);
    }

    public static AjaxResult error(String msg) {
        return new AjaxResult(ERROR, msg, null);
    }

    public static AjaxResult error() {
        return new AjaxResult(ERROR,ERROR_MSG,null);
    }
}
//package com.woniu.admin.vo;
//
//import lombok.Data;
//
//@Data
//public class AjaxResult {
//    private Integer code;
//    private String msg;
//    private Object data;
//
//    private static final Integer SUCCESS = 200;
//    private static final Integer ERROR = 500;
//
//    public AjaxResult(Integer code, String msg, Object data) {
//        this.code = code;
//        this.msg = msg;
//        this.data = data;
//    }
//
//
//    public static AjaxResult success(String msg, Object data) {
//        return new AjaxResult(SUCCESS, msg, data);
//    }
//
//    public static AjaxResult success(String msg) {
//        return new AjaxResult(SUCCESS, msg, null);
//    }
//
//    public static AjaxResult error(String msg, Object data) {
//        return new AjaxResult(ERROR, msg, data);
//    }
//
//    public static AjaxResult error(String msg) {
//        return new AjaxResult(ERROR, msg, null);
//    }
//}
